import * as vscode from 'vscode';
import { context } from '../utils/context';

const keys = ['func', 'import', 'private', 'public', 'protected', 'internal', 'class', 'struct', 'return', 'package', 'open', 'super', 'var', 'let', 'super', 'try', 'catch', 'finally', 'do', 'while', 'this', 'if', 'else', 'static', 'true', 'false', 'abstract', 'enum', 'interface', 'continue', 'break', 'where', 'for', 'in'];

export class keyCompletionItem {
    private static context: context;
    private static arr: vscode.CompletionItem[] = [];
    static create(mark: string, context: context) {
        this.arr = [];
        this.context = context;
        const tag = mark.toLowerCase(),
            arr = keys.filter((i) => i.startsWith(tag));
        this.newItems(arr);
        return this.arr;
    }

    private static newItems(marks: string[]) {
        for (const mark of marks) {
            const item = {
                label: mark,
                insertText: mark,
                range: this.context.importRange,
                kind: vscode.CompletionItemKind.Keyword
            };
            this.arr.push(item);
        }
    }
}